import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    userData: JSON.parse(localStorage.getItem("userData")) || null,
    isCollapse: false
  },
  mutations: {
    login(state, data) {
      // localStorage.setItem('token', data.token);
      localStorage.setItem('userData', JSON.stringify(data));
      // state.token = data.token;
      state.userData = data;
    },

    logout(state) {
      // localStorage.removeItem('token');
      localStorage.removeItem('userData');
      // state.token = null;
      state.userData = null;
    },

    toggleSideBar(state) {
      state.isCollapse = !state.isCollapse;
    }
  },
  actions: {},
  modules: {}
})